// 导航首页（计件工资，计时工资）

<template>
  <view class="mes-nav-index">
    <view
      class="nav-item"
      @tap="tapItem(item)"
      v-for="(item, index) in form.items"
      :key="index"
    >
      <view class="nav-left">
        <view class="nav-title">{{ item.title }}</view>
        <view class="nav-body">
          <view
            v-for="(cItem, cIndex) in item.body"
            :key="cIndex"
            class="nav-body-item"
          >
            <text>{{ cItem.name }}</text>
            <text>{{ cItem.value }}</text>
          </view>
        </view>
      </view>
      <view class="nav-right">
        <text class="iconfont icon-xiangyou1"></text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    form: {
      type: Object
    }
  },
  created() {
    console.log('form is', this.form)
  },
  methods: {
    tapItem(item) {
      if (this.form.tapItem) {
        this.form.tapItem(item)
      } else {
        console.warn('请在form中定义tapItem')
      }
    }
  }
}
</script>

<style lang="less" scoped>
.mes-nav-index {
  .nav-item {
    width: 702rpx;
    background: #ffffff;
    padding: 30rpx 28rpx 30rpx 24rpx;
    border-radius: 16rpx;
    margin: 0 auto;
    margin-top: 20rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
    &:first-child {
      margin-top: 0;
    }
    .nav-left {
      .nav-title {
        font-size: 28rpx;
        font-weight: 500;
      }
      .nav-body {
        margin-top: 8rpx;
        font-size: 24rpx;
        color: #666666;
      }
    }
    .nav-right {
      color: #999999;
    }
  }
}
</style>

